package com.nuit.cxl.bilibili.controller;

import com.nuit.cxl.bilibili.service.RecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RecommendController {

    private RecommendService recommendService;

    @GetMapping("get")
    public String[] getRecommend(){
        //XXXservice = new XXXserviceImpl
        //这边就先用new的形式，做得快的同学可以也写到配置文件里面让spring一起配置
        //然后获取service处理好的数据，返回出去

//        String[] strs = {"终于知道大家为什么喜欢用AI了","超标教s37最强边路私人超标英雄上分神器！月抛流哪吒"};
//        return strs;
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        recommendService = (RecommendService) ctx.getBean("recommendService");
        String[] strs = recommendService.fetchRecommend();
        return strs;
    }

    public RecommendService getRecommendService() {
        return recommendService;
    }

    public void setRecommendService(RecommendService recommendService) {
        this.recommendService = recommendService;
    }
}
